<template>
    <div class="btn">
        <el-button type="text" @click="upArticle" v-if="lastAndNextArticleP.list[0].length>0&&lastAndNextArticleP.list[0][0].title !=undefined">
            上一篇: 《{{lastAndNextArticleP.list[0][0].title}}》</el-button>
        <el-divider direction="vertical"></el-divider>
        <el-button type="text" @click="nextArticle" v-if="lastAndNextArticleP.list[1].length>0 && lastAndNextArticleP.list[1][0].title !=undefined">
            下一篇: 《{{lastAndNextArticleP.list[1][0].title}}》</el-button>
    </div>
</template>

<script>
    export default {
        props: ['data','dictype'],
        watch: {
            data(val) {
                // if (val) {
                this.lastAndNextArticle(val)
                // }
            }
        },
        created() {},
        mounted() {},
        data() {
            return {
                lastAndNextArticleP: []
            }
        },
        methods: {
            lastAndNextArticle(params) {
                this.$store.dispatch('articleModule/lastAndNextArticle', {
                    articleId: params.id,
                    creationTime: params.creationtime,
                    updateTime: params.updateTime || '2020-07-18 12:07:32',
                    userid: params.userid,
                    dictype: params.dictype?params.dictype:this.dictype,
                    sortType: params.sortType ? params.sortType : 0,
                }).then(res => {
                    this.lastAndNextArticleP = res
                })
            },
            upArticle() {
                this.$emit('articleFriendContent',this.lastAndNextArticleP.list[0][0])
            },
            nextArticle() {
                this.$emit('articleFriendContent',this.lastAndNextArticleP.list[1][0])
            }
        }
    }
</script>

<style>

</style>